import CONFIG from './config.js'

var host
if(CONFIG.ENV == 'TEST'){ host = CONFIG.TEST_HOST } 
if(CONFIG.ENV == 'PROD'){ host = CONFIG.PROD_HOST }

function service(options = {}){
  let array1 = {'Content-Type':'application/x-www-form-urlencoded'};
  options.header= array1
	options.url = host+options.url
	return new Promise((resolved,reject)=>{
		options.success = (res) => {
			if(res) resolved(res.data);
		}
		options.fail = (err) =>{ reject(err) }
		uni.request(options)
	}).catch((e)=>{})
}

export default service